package com.wang.avi.indicator;

import java.lang.ref.WeakReference;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.View;

/**
 * Created by Jack on 2015/10/15.
 */
public abstract class BaseIndicatorController {

	private WeakReference<View> mTarget;


    public void setTarget(View target){
        mTarget=new WeakReference<View>(target);
    }

    public View getTarget(){
        return mTarget.get();
    }

    public int getWidth(){
    	if (mTarget == null) return 0;
    	if (mTarget.get() == null) return 0;
        return mTarget.get().getWidth();
    }

    public int getHeight(){
    	if (mTarget == null) return 0;
    	if (mTarget.get() == null) return 0;
        return mTarget.get().getHeight();
    }

    public void postInvalidate(){
    	if (mTarget == null) return;
    	if (mTarget.get() == null) return;
    	mTarget.get().postInvalidate();
    }

    /**
     * draw indicator what ever
     * you want to draw
     * @param canvas
     * @param paint
     */
    public abstract void draw(Canvas canvas,Paint paint);

    /**
     * create animation or animations
     * ,and add to your indicator.
     */
    public abstract void createAnimation();

    public void clearAnimation(){};
}
